package vn.fpt.fsoft.cuongn.faces.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;

import vn.fpt.fsoft.cuongn.faces.model.Account;
import vn.fpt.fsoft.cuongn.util.DatabaseManager;

public class ListAccountDAO {

	public ArrayList<Account> getAccounts() throws ClassNotFoundException, SQLException {
		ArrayList<Account> list = new ArrayList<Account>();
		DatabaseManager dm = new DatabaseManager();
		ResultSet rs = null;
		String sql = "select * from Account";
		Statement st = dm.con.createStatement();
		rs = st.executeQuery(sql);
		while(rs.next()){
			Integer id = rs.getInt(1);
			String tenDangNhap = rs.getString(2);
			String passWord = rs.getString(3);
			String hoTen = rs.getString(4);
			String email = rs.getString(5);
			list.add(new Account(id, tenDangNhap, hoTen, passWord, email));
		}
		return list;
	}

}
